

//获取上一页的用户列表
function previous(queryUser){
    if(vm.users.currPage == 1){
        return ;
    }
    getUserList(queryUser);
}

function next(queryUser){
    if(vm.users.currPage == vm.users.totalPage){
        return ;
    }
    getUserList(queryUser);
}
//获取用户列表
//返回值：请求的返回值
function getUserList(queryUser){
    document.getElementById("loading").style.display = "block";
    var userUrl = getUserUrl(queryUser);
    $.ajax({
        type: "GET",
        url: userUrl,
        contentType: "application/json",
        success: function (r) {
            document.getElementById("loading").style.display = "none";
            if (r.code === 0) {
                vm.users = r.page;
                //判断总数有多少，来设置上一页和下一页是否可点击
                var next = document.getElementById("next");
                var previous = document.getElementById("previous");
                if (r.page.totalPage == 1 || r.page.currPage == 1) {
                    addClass(previous,"disabled");
                }else {
                    //如果总数不止一页，则需要设置可点击
                    removeClass(previous,"disabled");
                }

                if (r.page.currPage == r.page.totalPage){
                    addClass(next,"disabled");
                }else {
                    //如果总数不止一页，则需要设置可点击
                    removeClass(next,"disabled");
                }
            } else {

            }
        }
    });
}

//获取目标url
function getUserUrl(target){
    return baseURL + "user/userinfos/desclist?"+"searchParam="+target.username+"&limit="+target.limit+"&page="+target.page+"&order="+target.order;
}